/*
 * Copyright(c) 2024 长沙市希尚网络科技有限公司
 * 注意：本内容仅限于长沙市希尚网络科技有限公司内部传阅，禁止外泄以及用于其他的商业目的
 *//*


package org.ssssssss.example.sphere;

import org.apache.shardingsphere.distsql.parser.autogen.UtilityDistSQLStatementParser.ExecuteContext;
import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.SelectStatement;

*/
/**
 * TODO
 *
 * @author liuy
 * @version 1.0 2024/12/31 0031
 *//*

public class SQLRouteAndExecuteExample {

    public static void main(String[] args) {
        // 配置分片规则
        ShardingRule shardingRule = createShardingRule();

        // 解析 SQL 语句
        ExecuteContext SQLParseExample = null;
        SelectStatement sqlStatement = SQLParseExample.parseSQL("SELECT * FROM t_order WHERE order_id = 1");
        SelectStatementContext selectStatementContext = new SelectStatementContext(sqlStatement);
    }

    public static ShardingRule createShardingRule() {
        // 配置分片规则
        ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();

        // 配置分片表规则
        ShardingTableRuleConfiguration orderTableRuleConfig = new ShardingTableRuleConfiguration("t_order", "ds_${0..1}.t_order_${0..1}");
        orderTableRuleConfig.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "orderDatabaseShardingAlgorithm"));
        orderTableRuleConfig.setTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "orderTableShardingAlgorithm"));
        shardingRuleConfig.getTables().add(orderTableRuleConfig);

        // 配置分片算法
        shardingRuleConfig.getShardingAlgorithms().put("orderDatabaseShardingAlgorithm", new AlgorithmConfiguration("INLINE", "algorithm-props"));
        shardingRuleConfig.getShardingAlgorithms().put("orderTableShardingAlgorithm", new AlgorithmConfiguration("INLINE", "algorithm-props"));

        // 创建分片规则
        return new ShardingRule(shardingRuleConfig);
    }
}
*/
